import { createRouter, createWebHashHistory } from "vue-router";


const routes = [
  {
    path: "/home",
    name: "Home",
    component: () => import('@/views/Admin'),

  },
  {
    path: "/about",
    name: "About",
    component: () => import("../views/About.vue"),
  },
  {
    path: "/article/create",
    name: "ArticleCreate",
    component: () => import('@/views/ArticleCreate'),
  },
  {
    path: "/",
    name: "login",
    component: () => import('@/views/login'),
  },
];



const router = createRouter({
  history: createWebHashHistory(),
  routes,

});
router.beforeEach((to,from,next) => {
  if (to.path === '/') {
    next()
  }else {let token = localStorage.getItem('Authorization')
    if (token === 'null' || token === '') {
      next('/')
    }else {
      next()
    }
  }
})
export default router;
